// custom-tab-bar/index.js
import { storeBindingsBehavior } from 'mobx-miniprogram-bindings'
import {store} from '../store/store'
//const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },
  behaviors: [storeBindingsBehavior],
  storeBindings: {
    store,
    fields: {
      active: 'activeTabbarIndex'
    },
    actions: {
      updateActive: 'updateActiveTabbarIndex'
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    active: 0,
    list: [{
        "pagePath": "/pages/index/index",
        "text": "首页",
        "icon": "home-o",
      }, {
        "pagePath": "/pages/mall/mall",
        "text": "分类",
        "icon": "apps-o",
      }, {
        "pagePath": "/pages/cart/cart",
        "text": "购物车",
        "icon": "shopping-cart-o",
      },
      {
        "pagePath": "/pages/me/me",
        "text": "我的",
        "icon": "user-o",
      }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onChange(event) {
      this.updateActive(event.detail)
      wx.switchTab({
        url: this.data.list[event.detail].pagePath,
      })
    }
  }
})
